package com.weixing.mall.provider.controller.pdm;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.core.support.auth.SysAuth;
import com.weixing.mall.core.support.auth.SysInfo;
import com.weixing.mall.provider.model.dto.pdm.ProjectInfoDesignDto;
import com.weixing.mall.provider.model.dto.pdm.ProjectInfoDto;
import com.weixing.mall.provider.model.dto.pdm.ProjectInfoProductionDto;
import com.weixing.mall.provider.model.dto.pdm.ProjectInfoPurchaseDto;
import com.weixing.mall.provider.model.query.ProductDevelopQuery;
import com.weixing.mall.provider.service.IProjectInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wx
 * @Date 2019/9/10 11:43
 * @Version 1.0
 */
@RestController
@RequestMapping("projectInfo")
@Api(value = "样板部",tags ="样板部Api" )
public class ProjectInfoController extends BaseController {
    @Autowired
    private IProjectInfoService projectInfoService;

    @ApiOperation("查询设计部列表")
    @GetMapping("DesignList")
    public Result selectDesignList(ProductDevelopQuery productDevelopQuery){
        return ResultUtil.success(projectInfoService.selectDesignList(initMpPage(),productDevelopQuery));
    }

    @ApiOperation("设计部维护")
    @PostMapping("saveDesign")
    public Result saveDesign(@SysInfo SysAuth auth, ProjectInfoDesignDto projectInfoDesignDto){
        projectInfoService.saveDesign(projectInfoDesignDto,auth.getUid());
        return ResultUtil.success();
    }

    @ApiOperation("设计部删除")
    @PostMapping("delDesign")
    public Result delDesign(@SysInfo SysAuth auth,Long id,Long projectId){
        projectInfoService.delDesign(id,projectId,auth.getUid());
        return ResultUtil.success();
    }


    @ApiOperation("查询样板部列表")
    @GetMapping("SamplePlateList")
    public Result selectSamplePlateList(ProductDevelopQuery productDevelopQuery){
        return ResultUtil.success(projectInfoService.selectListOfPage(initMpPage(),productDevelopQuery));
    }

    @ApiOperation("样板部编辑")
    @PostMapping("saveSamplePlate")
    public Result saveSamplePlate(@SysInfo SysAuth auth,ProjectInfoDto projectInfoDto){
        projectInfoService.save(projectInfoDto,auth.getUid());
        return ResultUtil.success();
    }



    @ApiOperation("查询采购时间列表")
    @GetMapping("selectPurchaseList")
    public Result selectPurchaseList(ProductDevelopQuery productDevelopQuery){
        return ResultUtil.success(projectInfoService.selectPurchaseList(initMpPage(),productDevelopQuery));
    }

    @ApiOperation("采购时间编辑")
    @PostMapping("savePurchase")
    public Result savePurchase(@SysInfo SysAuth auth,ProjectInfoPurchaseDto projectInfoPurchaseDto){
        projectInfoService.savePurchase(projectInfoPurchaseDto,auth.getUid());
        return ResultUtil.success();
    }

    @ApiOperation("查询生产时间列表")
    @GetMapping("selectProductionList")
    public Result selectProductionList(ProductDevelopQuery productDevelopQuery){
        return ResultUtil.success(projectInfoService.selectProductionList(initMpPage(),productDevelopQuery));
    }

    @ApiOperation("生产时间编辑")
    @PostMapping("saveProduction")
    public Result saveProduction(@SysInfo SysAuth auth,ProjectInfoProductionDto projectInfoProductionDto){
        projectInfoService.saveProduction(projectInfoProductionDto,auth.getUid());
        return ResultUtil.success();
    }
}
